#!/bin/bash
echo ""
echo ""
echo "############################ 服务检查 ############################"
echo ""
centosVersion=$(awk '{print $(NF-1)}' /etc/redhat-release)
if [[ $centosVersion > 7 ]];then
    conf=$(systemctl list-unit-files --type=service --state=enabled --no-pager | grep "enabled")
    process=$(systemctl list-units --type=service --state=running --no-pager | grep ".service")
    #报表信息
    report_SelfInitiatedService="$(echo "$conf" | wc -l)" #自启动服务数量
    report_RuningService="$(echo "$process" | wc -l)" #运行中服务数量
else
    conf=$(/sbin/chkconfig | grep -E ":on|:启用")
    process=$(/sbin/service --status-all 2>/dev/null | grep -E "is running|正在运行")
    #报表信息
    report_SelfInitiatedService="$(echo "$conf" | wc -l)" #自启动服务数量
    report_RuningService="$(echo "$process" | wc -l)" #运行中服务数量
fi
echo "############################ 服务配置 ############################"
echo "$conf" | column -t
echo ""

echo "############################ 正在运行的服务 ############################"

echo "$process"
 